<div id="footer-widget-area-background">
<?php if ( get_post_meta($post->ID, 'footer_widget_check', true) != 'on' ) { get_sidebar('footer'); }  ?>
</div><!-- #footer-widget-area-background -->
<div id="bottom_elements_background">
<div id="bottom_elements">
<?php get_sidebar('copyright'); ?>
<div id="footer_navigation">
<?php wp_nav_menu( array('theme_location' => 'footer', 'container' => false, 'before' => '/', 'fallback_cb' => false)); ?>  
</div><!--#footer_navigation-->
<div class="clear"></div>
</div><!--#bottom_elements-->
</div><!--#bottom_elements_background-->

</div><!-- #wrapper -->
</div><!-- #aligner -->

<?php if (get_option_tree('disable_sliding_sidebar_opt', '')) {} else { ?>
<div class="sliding_sidebar closed" >  
	<div class="sliding_sidebar_content">
	<a class="handle" href="http://link-for-non-js-users"></a>
	<?php get_sidebar('sliding'); ?>
	</div>
</div>

<script>
	var $j = jQuery.noConflict();
	$j(function(){
	$j('.sliding_sidebar').tabSlideOut({
	pathToTabImage: '<?php bloginfo('stylesheet_directory'); ?>/images/footer_handle.png' });
	});
</script>
<?php }?>	

<?php 
if ( is_category()){
//$post_term = wp_get_post_terms( $post->ID, 'category' );
//$category_slug = $post_term[0]->slug;
$cat_id = get_query_var('category_name');
query_posts(array('post_type' => 'cat_head', 'category_name' => $cat_id,));  
if ( ! have_posts() ) {
		if (get_option_tree('full_width_background', '')) { 
		echo '<img id="bg" src="', get_option_tree('body_background_image', ''). '" class="hidden" alt="" />';}
}else{	
	while ( have_posts() ) : the_post(); 
	if ( get_post_meta($post->ID, 'page_color_choice', true) || get_post_meta($post->ID, 'page_image_choice', true)) {
		if ( get_post_meta($post->ID, 'footer_widget_check_bg', true) != 'off' ) {
			echo '<img id="bg" src="', get_post_meta($post->ID, 'page_image_choice', true). '" class="hidden" alt="" />'; 
		}	
	}	
	else{
		if (get_option_tree('full_width_background', '')) { 
		echo '<img id="bg" src="', get_option_tree('body_background_image', ''). '" class="hidden" alt="" />';}
	}
	endwhile;}
	wp_reset_query();
}
elseif (is_page_template('portfolio-one.php') || is_page_template('portfolio-two.php') || is_page_template('portfolio-three.php') || is_page_template('portfolio-four.php') || is_page_template('paged-portfolio-one.php') || is_page_template('paged-portfolio-two.php') || is_page_template('paged-portfolio-three.php') || is_page_template('paged-portfolio-four.php') ) {}
elseif (get_post_meta($post->ID, 'page_color_choice', true) && !is_home() || get_post_meta($post->ID, 'page_image_choice', true) && !is_home()) {
		if ( get_post_meta($post->ID, 'footer_widget_check_bg', true) != 'off' ) {
			echo '<img id="bg" src="', get_post_meta($post->ID, 'page_image_choice', true). '" class="hidden" alt="" />'; 
		}	
}
else {
	if ( is_single() && !is_post_type('portfolio')){
		$post_term = wp_get_post_terms( $post->ID, 'category' );
		$category_slug = $post_term[0]->slug;
		query_posts(array('post_type' => 'cat_head', 'category_name' => $category_slug,));  
		if ( ! have_posts() ) {
				if (get_option_tree('full_width_background', '')) { 
				echo '<img id="bg" src="', get_option_tree('body_background_image', ''). '" class="hidden" alt="" />';}
		}else{	
			while ( have_posts() ) : the_post(); 
			if ( get_post_meta($post->ID, 'page_color_choice', true) || get_post_meta($post->ID, 'page_image_choice', true)) {
				if ( get_post_meta($post->ID, 'footer_widget_check_bg', true) != 'off' ) {
					echo '<img id="bg" src="', get_post_meta($post->ID, 'page_image_choice', true). '" class="hidden" alt="" />'; 
				}	
			}	
			else{
				if (get_option_tree('full_width_background', '')) { 
				echo '<img id="bg" src="', get_option_tree('body_background_image', ''). '" class="hidden" alt="" />';}
			}
			endwhile;}
			wp_reset_query();
	}
	else{
		if(get_option_tree('full_width_background', '')) { 
		echo '<img id="bg" src="', get_option_tree('body_background_image', ''). '" class="hidden" alt="" />';}
	}
}?> 

<?php wp_footer(); ?>
<?php if (get_option_tree('disable_cufon_fonts', '')) {} else { ?>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/fonts/<?php get_option_tree('choose_cufon_font', '', true); ?>.js"></script>
<script type="text/javascript">
Cufon.replace('h1,h2,h3,h4,h5,h6,.su-service-title, .su-heading-shell, p.recent_post-title a, .su_au_name, .su-pricing-title, .su-pricing-value, .slidemenu a', {hover: true });
</script>
<script type="text/javascript"> Cufon.now(); </script>
<?php }?>
</body>
</html>